package com.admin.socketmultiplayer.activity

import android.support.v4.app.Fragment
import com.admin.socketmultiplayer.R
import com.admin.socketmultiplayer.bean.Room
import com.admin.socketmultiplayer.dialog.RoomListDialog
import com.admin.socketmultiplayer.fragment.HomeFragment
import com.admin.socketmultiplayer.fragment.UserFragment
import com.admin.socketmultiplayer.inteface.DialogListener
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.startActivity

class MainActivity : BaseActivity() {
    var homeFragment=HomeFragment()
    var userFragment=UserFragment()

    override fun bindLayout(): Int {
        return R.layout.activity_main
    }

    override fun initData() {
    }

    override fun initEvent() {
        rg_option.setOnCheckedChangeListener { radioGroup, i ->
            when(i){
                R.id.rb_home->{
                    initFragment(homeFragment)
                }
                R.id.rb_mine->{
                    initFragment(userFragment)
                }
            }
        }
        rg_option.check(R.id.rb_home)
    }

    fun initFragment(fragment:Fragment){
        var tran=supportFragmentManager.beginTransaction()
        tran.replace(R.id.fl_home_body,fragment)
        tran.commit()
    }


    override fun onStop() {
        super.onStop()

    }
}
